
<template>
  <div class="treeBox">
    <el-tree
      :data="data"
      :show-checkbox="true"
      node-key="id"
      ref="tree"
      :default-expand-all="isExpandAll"
      :props="defaultProps"
      @check-change="handleCheckChange"
    ></el-tree>
  </div>
</template>
<script>

export default {
    name: "TreeCheckbox",
    data() {
        return {
            defaultProps: {
                children: "children",
                label: this.label || 'name'
            },
        };
    },
    props:['isExpandAll', 'data', 'label'],
    watch: {

    },
    beforeCreate() {
      var _that = this;
      this.$ge.$on('set-tree-checkbox-select', (nodes) => {
        _that.$refs.tree.setCheckedKeys(nodes);
      })
    },
    created(){
    },
    mounted() {
      this.$ge.$on('tree-checkbox-dom-done', true)
    },
    methods: {

        handleCheckChange(data, value) {
          let res = this.$refs.tree.getCheckedNodes()
          let arr = []
          res.forEach((item) => {
            arr.push(item.id)
          })
        }

    },
    
   
};
</script>
<style scoped>
/* .treeBox {
  width: 200px;
} */
</style>

